package bb.lanxing.manager;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import bb.lanxing.R;


public class ShareDialogMgr {
    private static final String TAG = "ShareDialogMgr";
    private View mContent;
    private Context mContext;
    private LifeWatchAlertDialog mShareDialog;

    public void setStopListener(LifeWatchAlertDialog.OnDialogStopListener onDialogStopListener) {
        this.mShareDialog.setDialogStopListener(onDialogStopListener);
    }

    public ShareDialogMgr(Context context) {
        this.mContext = context;
    }

    public void setContent(View view) {
        this.mContent = view;
        this.mShareDialog = new LifeWatchAlertDialog(this.mContext, 3);
    }

    public View getContent() {
        return this.mContent;
    }

    public void show(boolean z) {
        if (this.mContent != null) {
            this.mShareDialog.show();
            Window window = this.mShareDialog.getWindow();
            assert window != null;
            WindowManager.LayoutParams attributes = window.getAttributes();
            attributes.width = MATCH_PARENT;
            attributes.height = WRAP_CONTENT;
            attributes.gravity = Gravity.CENTER;
            window.setContentView(this.mContent);
            window.setAttributes(attributes);
            if (z) {
                window.setWindowAnimations(R.style.Animation_SlideUpDown);
            }
        }
    }

    public void hide() {
        LifeWatchAlertDialog lifeWatchAlertDialog = this.mShareDialog;
        if (lifeWatchAlertDialog != null) {
            lifeWatchAlertDialog.dismiss();
        }
    }

    public boolean isShowing() {
        LifeWatchAlertDialog lifeWatchAlertDialog = this.mShareDialog;
        if (lifeWatchAlertDialog == null) {
            return false;
        }
        return lifeWatchAlertDialog.isShowing();
    }
}
